<template>
	<view>
		<!-- 提现账户管理-设置提现密码 -->
		<!-- #ifdef APP-PLUS -->
		<nav-bar title="提现账户管理-设置提现密码" leftIcon="back" @click-left="back">
			<block slot="right"><button class="cu-btn bg-blue margin-right-sm" @tap="save" :disabled="btndisabled">保存</button></block>
		</nav-bar>
		<!-- #endif -->
		<view class="cu-form-group padding-lr">
			<view class="title" style="width: 150rpx;">提现密码</view>
			<input type="text" v-model="payPassword" password placeholder="为保证资金资金账号安全，请设置提现密码" placeholder-class="text-gray text-df" />
		</view>
		<view class="cu-form-group padding-lr">
			<view class="title" style="width: 150rpx;">确认密码</view>
			<input type="text" v-model="payPasswords" password placeholder="请再次输入确认密码" placeholder-class="text-gray text-df" />
		</view>
		<view class="cu-form-group padding-lr">
			<view class="title" style="width: 150rpx;">验证码</view>
			<input type="number" length="6" v-model="verifyCode" placeholder="请输入手机验证码" placeholder-class="text-gray text-df" />
			<verfication-code type="resetPayPassword"></verfication-code>
		</view>
		<!-- #ifdef MP-WEIXIN -->
		<userButton @submitEvent="save" :btnDisabled="btndisabled">保存</userButton>
		<!-- #endif -->
		<loading :loadModal="loadModal"></loading>
	</view>
</template>

<script>
import userButton from '@/components/user-button.vue';
import verficationCode from '../../components/verfication-code.vue';
var _self; //this容器
export default {
	components: {
		userButton,
		verficationCode
	},
	data() {
		return {
			verifyCode: '',
			payPassword: '',
			payPasswords: '',
			type: 0,
			url: '',
			loadModal: false
		};
	},
	computed: {
		btndisabled() {
			if (this.payPassword.length > 5 && this.payPasswords.length > 5 && this.payPassword == this.payPasswords && this.verifyCode.length == 6) {
				return false;
			}
			return true;
		}
	},
	onLoad(options) {
		_self = this;
		if (options.t) {
			_self.type = options.t;
		}
		if (options.cnt) {
			_self.url = decodeURIComponent(options.cnt);
		}
	},
	methods: {
		/* 取消设置 */
		back() {
			uni.navigateBack({ delta: 1 });
		},

		/* 设置用户名 */
		save() {
			const param = {
				verifyCode: _self.verifyCode,
				payPassword: _self.payPassword
			};
			_self.loadModal = true;
			_self.$http.httpRequest('user/resetPayPassword', param, true).then(res => {
				_self.loadModal = false;
				if (res._tranStatus) {
					if (_self.type == 0 || _self.url.length == 0) {
						_self.back();
					} else {
						uni.redirectTo({
							url: _self.url
						});
					}
				} else {
					_self.$util.msg(res._exceptionLocalizedMessage);
				}
			});
		}
	}
};
</script>

<style lang="scss">
.text-section {
	background-color: white;
	padding: 30rpx 30rpx 0rpx 30rpx;
	input {
		position: relative;
		border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
		padding-left: 20rpx;
		margin-top: 10rpx;
		margin-bottom: 10rpx;
	}
	.info {
		font-size: 24rpx;
		color: #aaaaaa;
		margin-top: 10rpx;
	}
}
</style>
